<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".parent").children().hide();
	$(".parent").addClass("pointer").toggle(
		function(){$(this).children().show();
		},function(){$(this).children().hide();}
	);
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>退款日期</th>
	<td>
		<input type="text" name="begin_refund_time" class="datepicker" value="<?=isset($_GET['begin_refund_time']) ? $_GET['begin_refund_time'] : ''?>" /> to
		<input type="text" name="end_refund_time" class="datepicker" value="<?=isset($_GET['end_refund_time']) ? $_GET['end_refund_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>网站</th>
	<td><select name="shop_id">
		<option value="">请选择..</option>
		<?foreach ($shop as $s):?>
		<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id']) echo "selected='selected'";?>><?=$s['name']?></option>
		<?endforeach;?>
	</select></td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<?if (! empty($_GET['is_search'])):?>
<p><strong>退款次数：<?=$refund_count?></strong></p>
<ul style="list-style: disc; padding: 10px;">
<?if (! empty($refund_count)):?>
	<?foreach ($reason as $key => $r):?>
	<li style="margin: 5px;"><?=$r['name']?>：<?=$r['count']?> &nbsp; &nbsp;(<?=sprintf('%.2f', $r['count']/$refund_count*100). '%'?>)
		<ul style="list-style: circle;">
			<li style="margin-left: 15px;" class="parent">邮寄方式
				<ul>
				<?if (isset($r['shipping_method'])):?>
					<?foreach ($r['shipping_method'] as $k => $sm):?>
					<li><?=$k?> <?=$sm?></li>
					<?endforeach;?>
				<?endif;?>
				</ul>
			</li>
			<li style="margin-left: 15px;" class="parent">国家
				<ul>
				<?if (isset($r['country'])):?>
					<?foreach ($r['country'] as $k => $rc):?>
					<li><?=$k?> <?=$rc?></li>
					<?endforeach;?>
				<?endif;?>
				</ul>
			</li>
		</ul>
	</li>
	<?endforeach;?>
</ul>
<?endif;?>
<?endif;?>
<?php $this->_endblock();?>